﻿<%@ Page Title="Quản lý bảng giá theo ngày" MasterPageFile="~/Admin/Site.Master" Language="C#" AutoEventWireup="true" CodeBehind="QLBangGiaTheoNgayAdmin.aspx.cs" Inherits="Transport.Admin.QLBangGiaTheoNgayAdmin" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<%
if (Session["loainguoidung"] == null)
    {
        Response.Redirect("../Default.aspx");
    }
    else
    {
        if (Session["loainguoidung"].ToString() != "ADMIN")
            Response.Redirect("Default.aspx");
    }  
    %>
<p>
    <b>Biển số:</b>
    <asp:TextBox ID="txt_BienSo" runat="server"></asp:TextBox>
    <asp:Button ID="btn_Search" runat="server" Text="Tìm" />
</p>
<p>
    <b>Dịch vụ:</b>
    <asp:DropDownList ID="ddl_DV" runat="server" AutoPostBack="True" 
        DataSourceID="EntityDataSource_DV" DataTextField="ten_dich_vu" 
        DataValueField="id_dich_vu" AppendDataBoundItems="true">
        <asp:ListItem text="Select All" value="-1" />
    </asp:DropDownList>
    <asp:EntityDataSource ID="EntityDataSource_DV" runat="server" 
        ConnectionString="name=transportEntities" 
        DefaultContainerName="transportEntities" EnableFlattening="False" 
        EntitySetName="dich_vu" EntityTypeFilter="dich_vu">
    </asp:EntityDataSource>
    <b>Miền:</b>
    <asp:DropDownList ID="ddl_Mien" runat="server" AutoPostBack="True" 
        DataSourceID="EntityDataSource_Mien" DataTextField="ten_mien" 
        DataValueField="ma_mien" AppendDataBoundItems="true">
        <asp:ListItem text="Select All" value="-1" />
    </asp:DropDownList>
    <asp:EntityDataSource ID="EntityDataSource_Mien" runat="server" 
        ConnectionString="name=transportEntities" 
        DefaultContainerName="transportEntities" EnableFlattening="False" 
        EntitySetName="miens">
    </asp:EntityDataSource>
</p>
<div style="zoom: 1; overflow: auto;">
    <asp:GridView ID="GridView_Price" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" DataKeyNames="bien_so,ma_dich_vu" 
        DataSourceID="EntityDataSource_Price" CellPadding="4" ForeColor="#333333" CellSpacing="4"
        GridLines="None">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="bien_so" HeaderText="Biển số" ReadOnly="True" 
                SortExpression="bien_so" />
            <asp:TemplateField HeaderText="Dịch vụ">
                <ItemTemplate>
                    <asp:DropDownList ID="ddl_uDV" runat="server"
                        DataSourceID="EntityDataSource_DV" DataTextField="ten_dich_vu" 
                        DataValueField="id_dich_vu" SelectedValue='<%# Bind("ma_dich_vu") %>'>
                    </asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddl_uDV1" runat="server"
                        DataSourceID="EntityDataSource_DV" DataTextField="ten_dich_vu" 
                        DataValueField="id_dich_vu" SelectedValue='<%# Bind("ma_dich_vu") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Miền">
                <ItemTemplate>
                    <asp:DropDownList ID="ddl_uMien" runat="server" 
                        DataSourceID="EntityDataSource_Mien" DataTextField="ten_mien" 
                        DataValueField="ma_mien" SelectedValue='<%# Bind("ma_mien") %>'>
                    </asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddl_uMien1" runat="server" 
                        DataSourceID="EntityDataSource_Mien" DataTextField="ten_mien" 
                        DataValueField="ma_mien" SelectedValue='<%# Bind("ma_mien") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="gia_tien"  HeaderText="Giá tiền" 
                SortExpression="gia_tien" />
            <asp:BoundField DataField="gia_ngoai_gio"  HeaderText="Giá ngoài giờ" 
                SortExpression="gia_ngoai_gio" />
            <asp:BoundField DataField="gia_trang_tri"  HeaderText="Giá trang trí" 
                SortExpression="gia_trang_tri" />
            <asp:BoundField DataField="chi_phi_tai_xe"  HeaderText="Chi phí tài xế" 
                SortExpression="chi_phi_tai_xe" />
            <asp:BoundField DataField="phi_luu_dem"  HeaderText="Phí lưu đêm" 
                SortExpression="phi_luu_dem" />
        </Columns>
        <FooterStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#7FB308" ForeColor="#333333" HorizontalAlign="Center" />
        <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
        <SortedAscendingCellStyle BackColor="#FDF5AC" />
        <SortedAscendingHeaderStyle BackColor="#4D0000" />
        <SortedDescendingCellStyle BackColor="#FCF6C0" />
        <SortedDescendingHeaderStyle BackColor="#820000" />
    </asp:GridView>
    <asp:EntityDataSource ID="EntityDataSource_Price" runat="server" 
        ConnectionString="name=transportEntities" 
        DefaultContainerName="transportEntities" EnableDelete="True" 
        EnableFlattening="False" EnableInsert="True" EnableUpdate="True" 
        EntitySetName="bang_gia_trong_ngay"
        Where="it.ma_dich_vu = CASE WHEN @MaDV = '-1' THEN  it.ma_dich_vu ELSE @MaDV END 
        AND it.ma_mien = CASE WHEN @MaMien = '-1' THEN  it.ma_mien ELSE @MaMien END" >
        <WhereParameters>
            <asp:ControlParameter ControlID="ddl_DV" Type="String"
                Name="MaDV" PropertyName="SelectedValue"/>
            <asp:ControlParameter ControlID="ddl_Mien" Type="String"
                Name="MaMien" PropertyName="SelectedValue"/>
        </WhereParameters>
    </asp:EntityDataSource>
     <asp:QueryExtender ID="qeSearch" runat="server" TargetControlID="EntityDataSource_Price">
        <asp:SearchExpression DataFields="bien_so" SearchType="Contains">
            <asp:ControlParameter ControlID="txt_BienSo" />
        </asp:SearchExpression>
        <asp:OrderByExpression DataField="bien_so" Direction="Ascending" />
    </asp:QueryExtender>
</div>
<p>
    <asp:DetailsView ID="DetailsView_Price" runat="server" Height="50px" Width="125px" 
            AutoGenerateRows="False" DataKeyNames="bien_so,ma_dich_vu" 
            DataSourceID="EntityDataSource_Price" DefaultMode="Insert" 
            BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" 
        BorderWidth="1px" FieldHeaderStyle-Wrap="false"
            CellPadding="4" ForeColor="Black" GridLines="Horizontal" 
        oniteminserted="DetailsView_Price_ItemInserted">
        <EditRowStyle BackColor="White" ForeColor="Black" />
        <FieldHeaderStyle Wrap="False"></FieldHeaderStyle>
        <Fields>
            <asp:BoundField DataField="bien_so" HeaderText="Biển số" ReadOnly="True" 
                SortExpression="bien_so" />
            <asp:TemplateField HeaderText="Dịch vụ">
                <InsertItemTemplate>
                    <asp:DropDownList ID="ddl_iDV" runat="server"
                        DataSourceID="EntityDataSource_DV" DataTextField="ten_dich_vu" 
                        DataValueField="id_dich_vu" SelectedValue='<%# Bind("ma_dich_vu") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Miền">
                <InsertItemTemplate>
                    <asp:DropDownList ID="ddl_iMien" runat="server" 
                        DataSourceID="EntityDataSource_Mien" DataTextField="ten_mien" 
                        DataValueField="ma_mien" SelectedValue='<%# Bind("ma_mien") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="gia_tien" HeaderText="Giá tiền" 
                SortExpression="gia_tien" />
            <asp:BoundField DataField="gia_ngoai_gio" HeaderText="Giá ngoài giờ" 
                SortExpression="gia_ngoai_gio" />
            <asp:BoundField DataField="gia_trang_tri" HeaderText="Giá trang trí" 
                SortExpression="gia_trang_tri" />
            <asp:BoundField DataField="chi_phi_tai_xe" HeaderText="Chi phí tài xế" 
                SortExpression="chi_phi_tai_xe" />
            <asp:BoundField DataField="phi_luu_dem" HeaderText="Phí lưu đêm" 
                SortExpression="phi_luu_dem" />
            <asp:CommandField ShowInsertButton="True" />
        </Fields>
        <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
        <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
    </asp:DetailsView>
</p>
</asp:Content>